package com.yunshang.shoppingmall.ShopTask;

import com.yunshang.shoppingmall.common.IOFile;
import com.yunshang.shoppingmall.entity.ShopTaskState;

import java.text.SimpleDateFormat;
import java.util.Date;

public class ShopState {

    /**
     *
     * @param 项目
     * @param 消息
     * @param 总数
     * @param 位置
     * @param 成功
     * @param 失败
     * @param 跳过
     */
    public static void SetMsg(String project,String message,Integer total,Integer location,Integer suc,Integer fail,Integer skip)
    {
        //计算用时
        if(ShopTaskState.getDateStart()!=null)
        {
            ShopTaskState.setWhen((new Date()).getTime()-ShopTaskState.getDateStart().getTime());
        }
        ShopTaskState.setProject(project);
        ShopTaskState.setMessage(message);
        ShopTaskState.setTotal(total);
        ShopTaskState.setLocation(location);
        ShopTaskState.setSuc(suc);
        ShopTaskState.setFail(fail);
        ShopTaskState.setSkip(skip);
        String txt = ShopTaskState.toStringP();
        SimpleDateFormat sf = new SimpleDateFormat("yyyyMMdd");
        Date dNow = new Date();
        boolean bl = IOFile.SetTextT("/log/"+sf.format(dNow)+".txt",txt+"\r\n");
        System.out.println(bl+txt);
    }

}
